import SystemAjaxConfig from "./SystemAjaxConfig";

class SystemUtil {
    constructor(baseUrl) {
        this.baseUrl = baseUrl || '/';
    }

    ajax(url, type) {
        var ajax = new SystemAjaxConfig(url, type);
        return ajax;
    }

    pop(config) {
        return layer.open($.extend(config, {
            type: 2,
            shadeClose: true,
            shade: 0.8
        }));
    }


    popUrl(title, url, width, height) {
        return this.pop({title,content:url,area: [width, height]});
    }

    popFull(title, url) {
        let index = this.pop({title,content:url});
        layer.full(index);
    }

    confirmDel(url){
        let that=this;
        this.confirm('确定要删除当前行吗？',()=>{
            that.ajax(url).send().then(function (res) {
               location.reload();
            }).showMsg();
        });
    }
    confirm(content,yesFunction){
        layer.confirm(content, {icon: 3, title: "提示"}, yesFunction);
    }
    confirmOperation(content,url){
        let that=this;
        layer.confirm(content, {icon: 3, title: "提示"}, ()=>{
            that.ajax(url).send().then(function (res) {
                location.reload();
            }).showMsg();
        });
    }
}

export default SystemUtil
